﻿using System.Windows;
using System.Windows.Controls;
using System.Windows.Input;

namespace Poet.Resources
{
    partial class MenuResources
    {
        private void InvertIsChecked(object sender, RoutedEventArgs e)
        {
            var menuItem = (MenuItem)sender;
            if (!menuItem.IsCheckable) return;
            menuItem.IsChecked = !menuItem.IsChecked;
            e.Handled = true;
        }

        private void Handle(object sender, RoutedEventArgs e)
        {
            var menuItem = (MenuItem)sender;
            if (!menuItem.IsCheckable) return;
            e.Handled = true;
        }

        private void HandleKey(object sender, KeyEventArgs e)
        {
            if (e.Key != Key.Enter && e.Key != Key.Space) return;
            InvertIsChecked(sender, e);
        }
    }
}
